<template>
    
    <!-- 组件的模板 -->
    <div class="page">
        <div class="industry com-border-top com-border-bottom" v-for="p_item in industryArr">
            <h2 :id="p_item.id" :data-code="p_item.code"></span>{{p_item.text}}</h2>
            <ul>
                <template v-for="c_item in p_item.data">
                    <li v-if="industryName == c_item.text" style="color: #fa0;" @click="getCurrSelect(p_item.id,p_item.code,p_item.text,c_item.id,c_item.code,c_item.text)">{{c_item.text}}</li>
                    <li v-else @click="getCurrSelect(p_item.id,p_item.code,p_item.text,c_item.id,c_item.code,c_item.text)">{{c_item.text}}</li>
                </template>
            </ul>
        </div>
    </div> 
        
</template>

<script>
    /**
     *  引入工具类库 或 Native API
     *  example : import widget from 'gapi/widget'
     */
    import clientUi from 'gapi/clientUi.js'
    import widget from 'gapi/widget.js'
    import teamApi from 'clientApi/teamApi.js'
    import * as util from 'js/util.js'
    import cache from 'gapi/cache.js'
    import commonPage from 'clientApi/commonPage.js'
    /**
     *  引入组件 以及 组件接口(Action)
     *  example : import Somecomponents from 'components/Somecomponents/Somecomponents'
     */

    /**
     *  组件实例对象
     */
    export default {
        components: {

        },
        data: function(){
            return{
                industryName:'',
                industryArr:[]
            }
        },
        vuex: {
            getters: {

            },
            actions: {

            }
        },
        methods: {
            /**
             * 初始化
             * @method init
             * @public
             * @return {Null} void
             */
            init (){
                this.industryName = util.getUrddataString('industryName') == '请选择' ? '' : util.getUrddataString('industryName')
                
            },
            getCurrSelect (pid,pcode,ptext,cid,ccode,ctext){
                let thisKey = {
                    industrypid:pid,
                    industrycid:cid,
                    industrypcode:pcode,
                    industryccode:ccode
                } 
                let thisValue = {
                    ptext:ptext,
                    ctext:ctext
                }
                cache.getMemoryCache('webViewID',(data)=>{
                    if(data){
                        commonPage.goBack(1,{'key':thisKey,'value':thisValue,'type':1},data.webViewID)
                    }
                })
            }
        },
        created(){
             /*
            *
            *初始化的时候请求行业列表数据
            *存储在缓存里
            *
            */
            util.ajax({
                url:'/common/industry/get',
                type:'GET',
                data:{
                    team_id:0,
                    project_id:0,
                    category_id:''
                },
                timeout:10000,
                success:(obj) => {
                    // console.log(obj)
                    if(obj&&obj.errno == 0){
                        this.industryArr = obj.data
                    }else{
                        widget.toast(obj.errmsg)
                    }
                },
                error: (xhr, status) => {
                    widget.toast('服务器异常')
                },
                noNetwork: () => { 
                    // 无网络的回调
                    widget.toast('网络连接失败，请检查网络')
                }
            })

            this.init();
            
        }


        
    }

    
</script>

<!-- CSS 样式 -->
<style src="../../node_modules/weui/dist/style/weui.css"></style>
<style src="../../static/css/common.css"></style>
<style src="../../static/css/team.css"></style>



